﻿using RecruitStudents.Utility.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RecruitStudents.Utility;
using System.Data;

namespace RecruitStudents.Client.BLL
{
    class ServiceLottery
    {
        WS_Lottery.LotteryService lotteryService = new WS_Lottery.LotteryService();
        WS_Lottery.MySoapHeader objHeader = new WS_Lottery.MySoapHeader();
        internal ServiceLottery()
        {
            objHeader.Username = "admin";
            objHeader.Password = "xy";
            lotteryService.MySoapHeaderValue = objHeader;
        }
        public DataTable GetTB_Pad_SignedDataTable_New(string strExamPlaceNo, string strExamLevel, string strSpecialityKindsNO,
            string strExamYear, string strIdCard, string strName)
        {
            return lotteryService.GetTB_Pad_SignedDataTable_New(strExamPlaceNo, strExamLevel, strSpecialityKindsNO, strExamYear, strIdCard, strName).ToDataTable();
        }

        public DataTable CheckTB_Pad_Signed_New(string SpecialityKindsNO, string ExamLevel, string ExamArea, string idCard, string strExamYear)
        {
            return lotteryService.CheckTB_Pad_Signed_New(SpecialityKindsNO, ExamLevel, ExamArea, idCard, strExamYear).ToDataTable();
        }

        public JsonMessage MakeLottery_New(string SignUpID, string examinationID, string lotNo, string strExamPlaceNo, string strExamLevel, string strSpecNo, string strExamYear)
        {
            return lotteryService.MakeLottery_New(SignUpID, examinationID, lotNo, strExamPlaceNo, strExamLevel, strSpecNo, strExamYear).ToList<JsonMessage>();
        }


        public DataTable GetTB_Pad_SignedDataTable(string strGroupNO, string strExamLevel, string strSpecialityKindsNO)
        {
            DataTable result = lotteryService.GetTB_Pad_SignedDataTable(strGroupNO, strExamLevel, strSpecialityKindsNO).ToDataTable();
            if (result != null)
            {
                result.Columns.Add("IsCheck", typeof(bool));
                for (int i = 0; i < result.Rows.Count; i++)
                {
                    result.Rows[i]["IsCheck"] = false;
                }
            }
            return result;
        }

        public DataTable CheckTB_Pad_Signed(string SpecialityKindsNO, string ExamLevel, string ExamArea, string idCard)
        {
            return lotteryService.CheckTB_Pad_Signed(SpecialityKindsNO, ExamLevel, ExamArea, idCard).ToDataTable();
        }

        public JsonMessage MakeLottery(string strSignUpStudentsSpecialityID, string strGroupNo, string examinationID, string lotNo)
        {
            return lotteryService.MakeLottery(strSignUpStudentsSpecialityID, strGroupNo, examinationID, lotNo).ToList<JsonMessage>();
        }

        public bool CancelLottery(string strGroupNo, string signUpStudentsSpecialityId, string strSignedID)
        {
            JsonMessage message = lotteryService.CancelLottery(strGroupNo, signUpStudentsSpecialityId, strSignedID).ToList<JsonMessage>();
            if (message.State == "true")
            {
                return true;
            }
            return false;
        }

        public DataTable GetPad_QueueDataTable(string stExamRoomID, string strGroupNo)
        {
            return lotteryService.GetPad_QueueDataTable(stExamRoomID, strGroupNo).ToDataTable();
        }

        public DataTable GetPad_Queue_PrintDataTable(string ExamLevel, string stExamRoomID, string strGroupNO)
        {
            return lotteryService.GetPad_Queue_PrintDataTable(ExamLevel, stExamRoomID, strGroupNO).ToDataTable();
        }

        public bool MakeExamRoomQueue(List<Utility.Model.TB_Pad_Queue> list)
        {
            string strJson = JsonHelper.ObjectToJson(list);
            JsonMessage message = lotteryService.MakeExamRoomQueue(strJson).ToList<JsonMessage>();
            if (message.State == "true")
            {
                return true;
            }
            return false;
        }

        public bool CancelExamRoomQueue(string strQueueID)
        {
            JsonMessage message = lotteryService.CancelExamRoomQueue(strQueueID).ToList<JsonMessage>();
            if (message.State == "true")
            {
                return true;
            }
            return false;
        }

        public DataTable GetAppointmentGroupDataTable(string strExamPlaceID, string strSpecialityKindsNO, string strExamLevel)
        {
            return lotteryService.GetAppointmentGroupDataTable(strExamPlaceID, strSpecialityKindsNO, strExamLevel).ToDataTable();
        }
    }
}
